import sys
import itertools

if len(sys.argv) < 3:
    print("Please input two or more files to diff!")
    sys.exit(1)

def check_conflict(file1, file2):
    diffFlag = False
    with open(file1, 'r') as f1, open(file2, 'r') as f2:
        for line1, line2 in zip(f1, f2):
            folder1, filename1, result1 = line1.strip().replace(" ", "").split(',')
            folder2, filename2, result2 = line2.strip().replace(" ", "").split(',')

            # print('+'+result1+'+', '+'+result2+'+')
            if (result1 == 'Unrealizable' or result1 == 'Realizable') and (result2 == 'Unrealizable' or result2 == 'Realizable'):
                if result1 != result2:
                    diffFlag = True
                    print((folder1+'/'+filename1).ljust(18), result1, result2)
    return diffFlag

compare_lists = sys.argv[1:]

# choose two 

n = len(compare_lists)
for i in range(n):
    for j in range(i + 1, n):
        has_conflict_flag = False
        for compare_file in compare_lists:
            if check_conflict(compare_lists[i], compare_lists[j]):
                print("Conflicts found compared to \n\t{} \n\t are as above!!!".format(compare_file))
                has_conflict_flag = True
        if not has_conflict_flag:
            print("No conflicts found.")

